package com.ruoyi.app.controller;

import com.ruoyi.app.service.ChargeService;
import com.ruoyi.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "充电相关")
@RestController
@RequestMapping("/recharge")
public class ChargeController {

    @Autowired
    ChargeService chargeService;


    @ApiOperation("附近设备")
    @GetMapping("/near-charge-device")
    public AjaxResult nearChargeDevice(@RequestParam Double longitude, @RequestParam Double latitude
                                      ,String communityName,@RequestParam String appId){
        return AjaxResult.success(chargeService.nearChargeDevice(longitude,latitude,communityName,appId));
    }

    @ApiOperation("附近小区")
    @GetMapping("/near-charge-community")
    public AjaxResult nearChargeCommunity(@RequestParam Double longitude, @RequestParam Double latitude
            ,String communityName,@RequestParam String appId){
        return AjaxResult.success(chargeService.nearChargeCommunity(longitude,latitude,communityName,appId));
    }

    @ApiOperation("根据二维码获取插座设备信息")
    @GetMapping("/qc/device-info")
    public AjaxResult getQcDeviceInfo(@RequestParam String qcCode){
        return AjaxResult.success(chargeService.getQcDeviceInfo(qcCode));
    }

    @ApiOperation("根据小区获取设备列表")
    @GetMapping("/community/{communityId}/devices")
    public AjaxResult getDeviceListByCommunityId(@PathVariable Long communityId){
        return AjaxResult.success(chargeService.getDeviceListByCommunityId(communityId));
    }

    @ApiOperation("根据设备获取插座列表")
    @GetMapping("/device/{deviceId}/sockets")
    public AjaxResult sockets(@PathVariable Long deviceId){
        return AjaxResult.success(chargeService.sockets(deviceId));
    }

    @ApiOperation("搜索设备 设备名 设备编号 小区名称 联合搜索")
    @GetMapping("/devices/{value}")
    public AjaxResult findDevice(@PathVariable String value,@RequestParam String appId){
        return AjaxResult.success(chargeService.findDevice(value,appId));
    }

    @ApiOperation("根据小区获取临时充电配置")
    @GetMapping("/recharge-option")
    public AjaxResult rechargeOption(@RequestParam Long communityId){
        return AjaxResult.success(chargeService.rechargeOption(communityId));
    }

    @ApiOperation("根据小区获取钱包余额充值配置")
    @GetMapping("/balance-charge-option")
    public AjaxResult balanceChargeOption(@RequestParam Long communityId){
        return AjaxResult.success(chargeService.balanceChargeOption(communityId));
    }

    @ApiOperation("根据小区获取钱包包月充值配置")
    @GetMapping("/balance-combo-option")
    public AjaxResult balanceComboOption(@RequestParam Long communityId){
        return AjaxResult.success(chargeService.balanceComboOption(communityId));
    }

    @ApiOperation("根据小区获取电卡余额充值配置")
    @GetMapping("/balance-card-option")
    public AjaxResult balanceCardOption(@RequestParam Long communityId){
        return AjaxResult.success(chargeService.balanceCardOption(communityId));
    }

    @ApiOperation("根据设备编号获取设备信息")
    @GetMapping("/device-info/{deviceNum}")
    public AjaxResult getDeviceInfo(@PathVariable String deviceNum){
        return AjaxResult.success(chargeService.getDeviceInfo(deviceNum));
    }

    @ApiOperation("根据小区获取充电时间配置")
    @GetMapping("/consumption-option")
    public AjaxResult consumptionOption(@RequestParam Long communityId){
        return AjaxResult.success(chargeService.consumptionOption(communityId));
    }

    @ApiOperation("获取设备配置功率段")
    @GetMapping("/power-list")
    public AjaxResult powerList(@RequestParam Long deviceId){
        return AjaxResult.success(chargeService.powerList(deviceId));
    }

}
